package pattern.cor;

import pattern.cor.handler.PriceHanlder;

import java.util.Random;

/**
 * Created by boot on 8/30/15.
 */
public class Client {
    private PriceHanlder priceHanlder;

    public void setPriceHanlder(PriceHanlder priceHanlder) {
        this.priceHanlder = priceHanlder;
    }

    public void requestDiscount(float discount) {
        priceHanlder.processDiscount(discount);
    }


    public static void main(String[] args) {
        Client cli = new Client();
        cli.setPriceHanlder(PriceHandlerFactory.createPriceHandler());
        Random rand = new Random();
        for (int i = 1; i <= 100; i++) {
            System.out.print(i + ":");
            cli.requestDiscount(rand.nextFloat());
        }
    }
}
